<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="webroot" value="${pageContext.request.contextPath}" />
<script src="${pageContext.request.contextPath}/static/js/jquery-3.2.1.min.js" type="text/javascript" ></script>
<script src="${pageContext.request.contextPath}/static/lib/layui/layui.js" type="text/javascript" ></script>
<link rel="stylesheet" type="text/css" href="${webroot}/static/css/font.css"/>
<link rel="stylesheet" type="text/css" href="${webroot}/static/css/xadmin.css"/>
<link rel="stylesheet" type="text/css" href="${webroot}/static/lib/layui/css/layui.css"/>
 <link rel="shortcut icon" href="${webroot}/static/favicon.ico" type="image/x-icon" />
<script src="${webroot}/static/js/xadmin.js" type="text/javascript" ></script>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">闪打-管理登录</div>
        <div id="darkbannerwrap"></div>
        <form method="post" class="layui-form" >
            <input name="username" id="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" id="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="userlogin" style="width:100%;" type="button" id="buttons">
            <hr class="hr20" >
            <p style="color: red;"></p>
        </form>
    </div>
<script type="text/javascript">
   $(document).keyup(function(event){
	  if(event.keyCode ==13){
	    $("#buttons").trigger("click");
	  }
	});
  $("#buttons").click(function () {
		var url ='${webroot}/system/userlogin';
	    $.ajax({
			cache : false,
			type : "POST",
			url : url,
			async : false,
			dataType : "json",
			data : {
				userId : $("#username").val(),
				password : $("#password").val()
			},
			success : function(data) {
				if(data != null){
					if(data.success){
						window.location.href='${webroot}/system/main?userId='+data.content.userId;
					}else{
                      if($("#username").val() != null && $("#password").val()){
                    	  layer.msg(data.message);
					  }
					}
				}
			}
   }); 
  }) 
</script>
</body>
</html>